import request from '@/axios';
import {baseUrl} from '@/config/env';

export const loginByUsername = (username, password, code, redomStr) => request({
    url: baseUrl + 'portal/vue/login',
    method: 'post',
    dataType: 'json',
    meta: {
        isToken: false
    },
    data: {
        'USERNAME': username,
        'USERPWSD': password,
        'VERIFYCODE': code,
        'redomStr': redomStr,
        'USERFLAG': '1'
    },
    headers: {
        'content-type': 'application/x-www-form-urlencoded'
    }
})

export const getUserInfo = (token) => request({
    url: baseUrl + 'portal/vue/getUserInfo',
    method: 'post',
    dataType: 'json',
    data: {'TOKEN': token},
    headers: {
        'content-type': 'application/x-www-form-urlencoded'
    }
});

export const refeshToken = () => request({
    url: baseUrl + '/user/refresh',
    method: 'post'
})

export const getMenu = (type = 'SYS') => request({
    url: baseUrl + 'portal/vue/queryMenu',
    method: 'post',
    dataType: 'json',
    data:{
        'PLATSYSID':type
    },
    headers: {
        'content-type': 'application/x-www-form-urlencoded'
    }
});

export const getTopMenu = () => request({
    url: baseUrl + 'portal/vue/queryMenu',
    method: 'post',
    dataType: 'json',
    data:{
        'PLATSYSID':''
    },
    headers: {
        'content-type': 'application/x-www-form-urlencoded'
    }
});

export const sendLogs = (list) => request({
    url: baseUrl + '/user/logout',
    method: 'post',
    data: list
})

export const logout = () => request({
    url: baseUrl + 'portal/login/logout',
    meta: {
        isToken: false
    },
    method: 'get'
})